<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>工作台</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../../../lib/layui-v2.5.5/css/layui.css" media="all">
    <link rel="stylesheet" href="../../../lib/font-awesome-4.7.0/css/font-awesome.min.css" media="all">
    <link rel="stylesheet" href="../../../css/public.css" media="all">
    <style>
        .layui-card {
            border: 1px solid #f2f2f2;
            border-radius: 5px;
        }

        .icon {
            margin-right: 10px;
            color: #1aa094;
        }

        .icon-cray {
            color: #ffb800 !important;
        }

        .icon-blue {
            color: #1e9fff !important;
        }

        .icon-tip {
            color: #ff5722 !important;
        }

        .layuimini-qiuck-module {
            text-align: center;
            margin-top: 10px
        }

        .layuimini-qiuck-module a i {
            display: inline-block;
            width: 100%;
            height: 60px;
            line-height: 60px;
            text-align: center;
            border-radius: 2px;
            font-size: 30px;
            background-color: #F8F8F8;
            color: #333;
            transition: all .3s;
            -webkit-transition: all .3s;
        }

        .layuimini-qiuck-module a cite {
            position: relative;
            top: 2px;
            display: block;
            color: #666;
            text-overflow: ellipsis;
            overflow: hidden;
            white-space: nowrap;
            font-size: 14px;
        }

        .welcome-module {
            width: 100%;
            height: 210px;
        }

        .panel {
            background-color: #fff;
            border: 1px solid transparent;
            border-radius: 3px;
            -webkit-box-shadow: 0 1px 1px rgba(0, 0, 0, .05);
            box-shadow: 0 1px 1px rgba(0, 0, 0, .05)
        }

        .panel-body {
            padding: 10px
        }

        .panel-title {
            margin-top: 0;
            margin-bottom: 0;
            font-size: 12px;
            color: inherit
        }

        .label {
            display: inline;
            padding: .2em .6em .3em;
            font-size: 75%;
            font-weight: 700;
            line-height: 1;
            color: #fff;
            text-align: center;
            white-space: nowrap;
            vertical-align: baseline;
            border-radius: .25em;
            margin-top: .3em;
        }

        .layui-red {
            color: red
        }

        .main_btn>p {
            height: 40px;
        }

        .layui-bg-number {
            background-color: #F8F8F8;
        }

        .layuimini-notice:hover {
            background: #f6f6f6;
        }

        .layuimini-notice {
            padding: 7px 16px;
            clear: both;
            font-size: 12px !important;
            cursor: pointer;
            position: relative;
            transition: background 0.2s ease-in-out;
        }

        .layuimini-notice-title,
        .layuimini-notice-label {
            padding-right: 70px !important;
            text-overflow: ellipsis !important;
            overflow: hidden !important;
            white-space: nowrap !important;
        }

        .layuimini-notice-title {
            line-height: 28px;
            font-size: 14px;
        }

        .layuimini-notice-extra {
            position: absolute;
            top: 50%;
            margin-top: -8px;
            right: 16px;
            display: inline-block;
            height: 16px;
            color: #999;
        }
    </style>
</head>

<body>
    <!--搜索开始-->
    <fieldset class="layui-elem-field layuimini-search">
        <legend>搜索信息</legend>
        <div style="margin: 10px 10px 10px 10px">
            <form class="layui-form layui-form-pane" action="" id="searchFrm">
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">开始时间</label>
                        <div class="layui-input-inline">
                            <input type="text" name="startTime" id="startTime" readonly="readonly" autocomplete="off"
                                class="layui-input">
                        </div>
                    </div>

                    <div class="layui-inline">
                        <label class="layui-form-label">结束时间</label>
                        <div class="layui-input-inline">
                            <input type="text" name="endTime" id="endTime" readonly="readonly" autocomplete="off"
                                class="layui-input">
                        </div>
                    </div>
                    <a class="layui-btn " lay-submit="" lay-filter="data-search-btn"><label
                            class="layui-icon layui-icon-search"></label>搜索</a>
                    <a class="layui-btn layui-btn-warm" onclick="javascript:$('#searchFrm')[0].reset()"
                        lay-filter="data-search-btn"><label class="layui-icon layui-icon-refresh"></label>重置</a>
                </div>
            </form>
        </div>
    </fieldset>
    <!--搜索结束-->

    <div class="layuimini-container">
        <div class="layuimini-main">
            <div class="layui-row layui-col-space15">
                <div class="layui-col-lg12">
                    <div class="layui-row layui-col-space15">
                        <div class="layui-col-md12">
                            <div class="layui-card">
                                <div class="layui-card-header"><i class="fa fa-warning icon"></i>数据统计</div>
                                <div class="layui-card-body">
                                    <div class="welcome-module">
                                        <div class="layui-row layui-col-space10">

                                            <div class="layui-col-xs6">
                                                <div class="panel layui-bg-number">
                                                    <div class="panel-body">
                                                        <div class="panel-title">
                                                            <span class="label pull-right layui-bg-blue">实时</span>
                                                            <h5>进货金额</h5>
                                                        </div>
                                                        <div class="panel-content">
                                                            <h1 class="no-margins" id='Outlay'>*****元</h1>
                                                            <small>当前进货总金额</small>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>

                                            <div class="layui-col-xs6">
                                                <div class="panel layui-bg-number">
                                                    <div class="panel-body">
                                                        <div class="panel-title">
                                                            <span class="label pull-right layui-bg-cyan">实时</span>
                                                            <h5>销售金额</h5>
                                                        </div>
                                                        <div class="panel-content">
                                                            <h1 class="no-margins" id='Revenue'>*****元</h1>
                                                            <small>当前销售总金额</small>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>

                                            <div class="layui-col-xs6">
                                                <div class="panel layui-bg-number">
                                                    <div class="panel-body">
                                                        <div class="panel-title">
                                                            <span class="label pull-right layui-bg-orange">实时</span>
                                                            <h5>库存商品统计</h5>
                                                        </div>
                                                        <div class="panel-content">
                                                            <h1 class="no-margins" id='Goodsnum'></h1>
                                                            <small>当前商品总记录数</small>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="layui-col-xs6">
                                                <div class="panel layui-bg-number">
                                                    <div class="panel-body">
                                                        <div class="panel-title">
                                                            <span class="label pull-right layui-bg-cyan">实时</span>
                                                            <h5>超市金额</h5>
                                                        </div>
                                                        <div class="panel-content">
                                                            <h1 class="no-margins" id='Marketsum'>*****元</h1>
                                                            <small>当前超市总金额</small>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>



                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>


                    </div>
                    <div class="layui-col-lg12">
                        <div class="layui-card">
                            <div class="layui-card-header"><i class="fa fa-line-chart icon"></i>报表统计</div>
                            <div class="layui-card-body">
                                <div id="echarts-records" style="width: 100%;min-height:500px"></div>
                            </div>
                        </div>

                        <div class="layui-card">
                            <div class="layui-card-header"><i class="fa fa-line-chart icon"></i>畅销商品类型</div>
                            <div class="layui-card-body">
                                <div id="echarts-records2" style="width: 100%;min-height:500px"></div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="layui-col-md4">


            </div>
        </div>
    </div>
    </div>
    <script type="text/javascript" src="https://lib.baomitu.com/echarts/5.1.0/echarts.min.js"></script>
    <script src="../../../lib/jquery-3.4.1/jquery-3.4.1.min.js" charset="utf-8"></script>
    <script src="../../../lib/layui-v2.5.5/layui.js" charset="utf-8"></script>
    <script src="../../../js/lay-config.js?v=1.0.4" charset="utf-8"></script>
    <script src="../../../lib/jq-module/jquery.particleground.min.js" charset="utf-8"></script>
    <script src="../../../lib/common/jquery.cookie.min.js" charset="utf-8"></script>
    <script src="../../../lib/common/common.js" charset="utf-8"></script>
    <script>



        layui.use(['form', 'table', 'laydate', 'layer'], function () {
            var form = layui.form;
            var table = layui.table;
            var laydate = layui.laydate;
            var layer = layui.layer;

            //渲染时间选择器
            laydate.render({
                elem: '#startTime',
                type: 'datetime'
            });
            laydate.render({
                elem: '#endTime',
                type: 'datetime'
            });
            $.get(api + "reports/queryGoodsnum", function (res) {
                $('#Goodsnum').text(res + '(件)')
            });
            $.get(api + "reports/queryMarketsum", function (res) {
                $('#Marketsum').text(res + '(元)')
            });
            // 监听搜索操作

            form.on('submit(data-search-btn)', function (data) {
                $.get(api + "reports/queryGoodsnum", function (res) {
                    $('#Goodsnum').text(res + '(件)')
                });
                $.get(api + "reports/queryInports", data.field, function (res) {
                    $('#Outlay').text(res + '(元)')
                    $.get(api + "reports/querySales", data.field, function (res) {
                        $('#Revenue').text(res + '(元)')
                    });





                    var data_goodsname = [];
                    var data_goodsnum = [];
                    $.get(api + "reports/querySalableGoods", data.field, function (res) {
                        for (i in res) {
                            data_goodsname.push(Object.keys(res[i])[0]);
                            data_goodsnum.push(Object.values(res[i])[0]);
                        }
                        $('#Salablegoods').text(Object.keys(res[0]))

                    }
                    );
                });

                /**
                 * 报表功能
                 */
                var echartsRecords = echarts.init(document.getElementById('echarts-records'), 'walden');
                var chartDom = document.getElementById('echarts-records');
                var myChart = echarts.init(chartDom);
                var option;

                $.get(api + "reports/querySalableGoods", data.field, function (res) {
                    var data_goodsname = [];
                    var data_goodsnum = [];
                    for (i in res) {
                        data_goodsname.push(Object.keys(res[i])[0]);
                        data_goodsnum.push(Object.values(res[i])[0]);

                    }
                    //倒置
                    data1 = data_goodsname.reverse()
                    data2 = data_goodsnum.reverse()
                    $.get().done(function (res) {
                        var optionRecords = {
                            tooltip: {

                                trigger: 'axis',
                                axisPointer: {
                                    type: 'shadow'

                                }
                            },
                        },
                            option = {
                                title: {
                                    text: '畅销商品排行榜'
                                },

                                legend: {},
                                grid: {
                                    left: '3%',
                                    right: '4%',
                                    bottom: '3%',
                                    containLabel: true
                                },
                                xAxis: {
                                    type: 'value',
                                    boundaryGap: [0, 0.01]
                                },
                                yAxis: {
                                    type: 'category',
                                    data: data1
                                },
                                series: [
                                    {
                                        name: '销售量',
                                        type: 'bar',
                                        barWidth: 20,
                                        itemStyle: {
                                            normal: {
                                                color: function (params) {

                                                    // build a color map as your need.

                                                    var colorList = [
                                                        '#C1232B', '#B5C334', '#FCCE10', '#E87C25', '#27727B',

                                                        '#FE8463', '#9BCA63', '#FAD860', '#F3A43B', '#60C0DD',

                                                        '#C1232B', '#B5C334', '#FCCE10', '#E87C25', '#27727B',

                                                        '#FE8463', '#9BCA63', '#FAD860', '#F3A43B', '#60C0DD',

                                                        '#D7504B', '#C6E579', '#F4E001', '#F0805A', '#26C0C0'

                                                    ];

                                                    return colorList[params.dataIndex]

                                                },
                                            }
                                        },

                                        data: data2

                                    }
                                ]
                            }
                        option && myChart.setOption(option);
                        echartsRecords.setOption(optionRecords);


                        $.get(api + "reports/querySalableGoodsType", data.field, function (res) {
                            console.log(res);
                            var data_typename = [];
                            var data_goodsnum = [];
                            for (i in res) {
                                data_typename.push(Object.keys(res[i])[0]);
                                data_goodsnum.push(Object.values(res[i])[0]);

                            }
                            console.log(data_typename);
                            console.log(data_goodsnum);
                            var echartsRecords2 = echarts.init(document.getElementById('echarts-records2'), 'walden');
                            var chartDom2 = document.getElementById('echarts-records2');
                            var myChart2 = echarts.init(chartDom2);
                            var option2;

                            option2 = {
                                title: {
                                    text: '畅销商品类型',
                                    subtext: '供应商名称代替',
                                    left: 'center'
                                },
                                tooltip: {
                                    trigger: 'item'
                                },
                                legend: {
                                    orient: 'vertical',
                                    left: 'left'
                                },
                                series: [
                                    {
                                        name: 'Access From',
                                        type: 'pie',
                                        radius: '50%',

                                        data: [



                                            { value: data_goodsnum[0], name: data_typename[0] },
                                            { value: data_goodsnum[1], name: data_typename[1] },
                                            { value: data_goodsnum[2], name: data_typename[2] },
                                            { value: data_goodsnum[3], name: data_typename[3] },
                                            { value: data_goodsnum[4], name: data_typename[4] }
                                        ],

                                        emphasis: {
                                            itemStyle: {
                                                shadowBlur: 10,
                                                shadowOffsetX: 0,
                                                shadowColor: 'rgba(0, 0, 0, 0.5)'
                                            }
                                        }
                                    }
                                ]
                            };
                            option2 && myChart2.setOption(option2);
                            // option2 && echartsRecords2.setOption(optionRecords2);
                            window.onresize = function () {
                                echartsRecords.resize();
                                echartsRecords2.resize();
                            }
                        });
                    });
                });
            });

        })



    </script>
</body>

</html>